package cn.lili.controller.feign.union;

import cn.lili.modules.member.client.UnionClient;
import cn.lili.modules.member.entity.dos.Union;
import cn.lili.modules.union.service.UnionService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequiredArgsConstructor
public class UnionFeignController implements UnionClient {

    private final UnionService unionService;
    @Override
    public List<Union> getList() {
        LambdaQueryWrapper<Union> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Union::getDeleteFlag, false);
        return unionService.list(queryWrapper);
    }

    @Override
    public List<Union> getListByIdList(List<String> unionIdList) {
        LambdaQueryWrapper<Union> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Union::getDeleteFlag, false);
        queryWrapper.in(Union::getId, unionIdList);
        queryWrapper.select(Union::getId, Union::getUnionName);
        return unionService.list(queryWrapper);
    }

    @Override
    public List<Union> getListByChairmanIdList(List<String> chairmanIdList) {
        LambdaQueryWrapper<Union> unionLambdaQueryWrapper = new LambdaQueryWrapper<>();
        unionLambdaQueryWrapper.in(Union::getChairmanId, chairmanIdList);
        return unionService.list(unionLambdaQueryWrapper);
    }

    @Override
    public List<Union> getListByFiled(String filed, String filedValue) {
        QueryWrapper<Union> unionLambdaQueryWrapper = new QueryWrapper<>();
        unionLambdaQueryWrapper.like(filed, filedValue);
        return unionService.list(unionLambdaQueryWrapper);
    }

    @Override
    public Union getById(String id) {
        return unionService.getById(id);
    }
}
